import socket,time,threading

def client_thread(i):
    server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)    # 创建UDP套接字
    host="127.0.0.1"
    port=12344
    
    num = 1
    server.sendto("{}:hello".format(i).encode("utf-8"),(host,port))
    while True:
        receive_data,addr = server.recvfrom(1024)
        print('接收的内容：'+ receive_data.decode("utf-8"))
        server.sendto("{}num:{}".format(i,num).encode("utf-8"),(host,port))
        num = (num + 1) % 100
        time.sleep(2)
    server.close()


t2 = threading.Thread(target=client_thread, args=(0,))
t1 = threading.Thread(target=client_thread, args=(1,))

t1.start()
t2.start()

t1.join()
t2.join()